﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using com.ClickCricket.bll;

public partial class PlayerDetails : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string path = Server.MapPath("Home.aspx");
        try
        {
            int cID = Convert.ToInt16(Request.Params.Get(0));
            using (var dc = new Context.CricketAdminmDataContext())
            {
                Table t = new Table();
                var pStats = from aPStats in dc.PlayerStatisticsTables
                             where aPStats.PlayerID == cID
                             select aPStats;
                if (pStats.Count<Entity.PlayerStatisticsTable>() == 1)
                {
                    TableRow tr = new TableRow();
                    TableCell tc = new TableCell();
                    tc.Controls.Add(new LiteralControl("Batting Innings::"));
                    tr.Cells.Add(tc);
                    tc = new TableCell();
                    tc.Controls.Add(new LiteralControl(pStats.Single<Entity.PlayerStatisticsTable>().BattingInn.ToString()));
                    tr.Cells.Add(tc);
                    t.Rows.Add(tr);
                    tr = new TableRow();
                    tc = new TableCell();
                    tc.Controls.Add(new LiteralControl("Bowling Innings::"));
                    tr.Cells.Add(tc);
                    tc = new TableCell();
                    tc.Controls.Add(new LiteralControl(pStats.Single<Entity.PlayerStatisticsTable>().BowlingInn.ToString()));
                    tr.Cells.Add(tc);
                    t.Rows.Add(tr);
                    tr = new TableRow();
                    tc = new TableCell();
                    tc.Controls.Add(new LiteralControl("Not Outs::"));
                    tr.Cells.Add(tc);
                    tc = new TableCell();
                    tc.Controls.Add(new LiteralControl(pStats.Single<Entity.PlayerStatisticsTable>().NotOut.ToString()));
                    tr.Cells.Add(tc);
                    t.Rows.Add(tr);
                    tr = new TableRow();
                    tc = new TableCell();
                    tc.Controls.Add(new LiteralControl("Runs::"));
                    tr.Cells.Add(tc);
                    tc = new TableCell();
                    tc.Controls.Add(new LiteralControl(pStats.Single<Entity.PlayerStatisticsTable>().Runs.ToString()));
                    tr.Cells.Add(tc);
                    t.Rows.Add(tr);
                    tr = new TableRow();
                    tc = new TableCell();
                    tc.Controls.Add(new LiteralControl("Highest Score::"));
                    tr.Cells.Add(tc);
                    tc = new TableCell();
                    tc.Controls.Add(new LiteralControl(pStats.Single<Entity.PlayerStatisticsTable>().HighScore.ToString()));
                    tr.Cells.Add(tc);
                    t.Rows.Add(tr);
                    tr = new TableRow();
                    tc = new TableCell();
                    tc.Controls.Add(new LiteralControl("Bowls Faced::"));
                    tr.Cells.Add(tc);
                    tc = new TableCell();
                    tc.Controls.Add(new LiteralControl(pStats.Single<Entity.PlayerStatisticsTable>().BowlsFaced.ToString()));
                    tr.Cells.Add(tc);
                    t.Rows.Add(tr);

                    tr = new TableRow();
                    tc = new TableCell();
                    tc.Controls.Add(new LiteralControl("No. of Hundreds::"));
                    tr.Cells.Add(tc);
                    tc = new TableCell();
                    tc.Controls.Add(new LiteralControl(pStats.Single<Entity.PlayerStatisticsTable>().Hundreds.ToString()));
                    tr.Cells.Add(tc);
                    t.Rows.Add(tr);
                    tr = new TableRow();
                    tc = new TableCell();
                    tc.Controls.Add(new LiteralControl("No. of Fifties::"));
                    tr.Cells.Add(tc);
                    tc = new TableCell();
                    tc.Controls.Add(new LiteralControl(pStats.Single<Entity.PlayerStatisticsTable>().Fifties.ToString()));
                    tr.Cells.Add(tc);
                    t.Rows.Add(tr);

                    tr = new TableRow();
                    tc = new TableCell();
                    tc.Controls.Add(new LiteralControl("No. of Sixes::"));
                    tr.Cells.Add(tc);
                    tc = new TableCell();
                    tc.Controls.Add(new LiteralControl(pStats.Single<Entity.PlayerStatisticsTable>().Sixes.ToString()));
                    tr.Cells.Add(tc);
                    t.Rows.Add(tr);

                    tr = new TableRow();
                    tc = new TableCell();
                    tc.Controls.Add(new LiteralControl("No. of Fours::"));
                    tr.Cells.Add(tc);
                    tc = new TableCell();
                    tc.Controls.Add(new LiteralControl(pStats.Single<Entity.PlayerStatisticsTable>().Fours.ToString()));
                    tr.Cells.Add(tc);
                    t.Rows.Add(tr);

                    tr = new TableRow();
                    tc = new TableCell();
                    tc.Controls.Add(new LiteralControl("No. of Catches::"));
                    tr.Cells.Add(tc);
                    tc = new TableCell();
                    tc.Controls.Add(new LiteralControl(pStats.Single<Entity.PlayerStatisticsTable>().Catches.ToString()));
                    tr.Cells.Add(tc);
                    t.Rows.Add(tr);

                    tr = new TableRow();
                    tc = new TableCell();
                    tc.Controls.Add(new LiteralControl("No. of Stumpings::"));
                    tr.Cells.Add(tc);
                    tc = new TableCell();
                    tc.Controls.Add(new LiteralControl(pStats.Single<Entity.PlayerStatisticsTable>().Stumpings.ToString()));
                    tr.Cells.Add(tc);
                    t.Rows.Add(tr);

                    tr = new TableRow();
                    tc = new TableCell();
                    tc.Controls.Add(new LiteralControl("Balls Bowled::"));
                    tr.Cells.Add(tc);
                    tc = new TableCell();
                    tc.Controls.Add(new LiteralControl(pStats.Single<Entity.PlayerStatisticsTable>().BallsBowled.ToString()));
                    tr.Cells.Add(tc);
                    t.Rows.Add(tr);

                    tr = new TableRow();
                    tc = new TableCell();
                    tc.Controls.Add(new LiteralControl("Run's Given::"));
                    tr.Cells.Add(tc);
                    tc = new TableCell();
                    tc.Controls.Add(new LiteralControl(pStats.Single<Entity.PlayerStatisticsTable>().RunsGiven.ToString()));
                    tr.Cells.Add(tc);
                    t.Rows.Add(tr);

                    tr = new TableRow();
                    tc = new TableCell();
                    tc.Controls.Add(new LiteralControl("No. of Wickets Taken::"));
                    tr.Cells.Add(tc);
                    tc = new TableCell();
                    tc.Controls.Add(new LiteralControl(pStats.Single<Entity.PlayerStatisticsTable>().WicketsTaken.ToString()));
                    tr.Cells.Add(tc);
                    t.Rows.Add(tr);

                    tr = new TableRow();
                    tc = new TableCell();
                    tc.Controls.Add(new LiteralControl("Best Innings::"));
                    tr.Cells.Add(tc);
                    tc = new TableCell();
                    tc.Controls.Add(new LiteralControl(pStats.Single<Entity.PlayerStatisticsTable>().BestInnings.ToString()));
                    tr.Cells.Add(tc);
                    t.Rows.Add(tr);


                    tr = new TableRow();
                    tc = new TableCell();
                    tc.Controls.Add(new LiteralControl("Best Match::"));
                    tr.Cells.Add(tc);
                    tc = new TableCell();
                    tc.Controls.Add(new LiteralControl(pStats.Single<Entity.PlayerStatisticsTable>().BestMaches.ToString()));
                    tr.Cells.Add(tc);
                    t.Rows.Add(tr);

                    tr = new TableRow();
                    tc = new TableCell();
                    tc.Controls.Add(new LiteralControl("No. of Five wickets::"));
                    tr.Cells.Add(tc);
                    tc = new TableCell();
                    tc.Controls.Add(new LiteralControl(pStats.Single<Entity.PlayerStatisticsTable>().FiveWickets.ToString()));
                    tr.Cells.Add(tc);
                    t.Rows.Add(tr);
                    Master.FindControl("ContentPlaceHolder1").Controls.Add(t);
                }
            }
        }
        catch
        {
            Server.Transfer("Home.aspx");
        }
    }
}
